home *** CD-ROM | disk | FTP | other *** search
/ This Disc Bytes! / Power Computing - The Disc 2 - This Disc Bytes.ISO / mac / CodeWarrior 7 Lite for 68K / MacOS Support / Headers / Universal Headers / Menus.h < prev    next >
Text File  |  1995-07-06  |  12KB  |  327 lines

  1. /*
  2.      File:        Menus.h
  3.  
  4.      Contains:    Menu Manager Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Package:    Universal Interfaces 2.1 in “MPW Latest” on ETO #18
  8.  
  9.      Copyright:    © 1984-1995 by Apple Computer, Inc.
  10.                  All rights reserved.
  11.  
  12.      Bugs?:        If you find a problem with this file, use the Apple Bug Reporter
  13.                  stack.  Include the file and version information (from above)
  14.                  in the problem description and send to:
  15.                      Internet:    apple.bugs@applelink.apple.com
  16.                      AppleLink:    APPLE.BUGS
  17.  
  18. */
  19.  
  20. #ifndef __MENUS__
  21. #define __MENUS__
  22.  
  23.  
  24. #ifndef __MEMORY__
  25. #include <Memory.h>
  26. #endif
  27. /*    #include <Types.h>                                            */
  28. /*        #include <ConditionalMacros.h>                            */
  29. /*    #include <MixedMode.h>                                        */
  30.  
  31. #ifndef __QUICKDRAW__
  32. #include <Quickdraw.h>
  33. #endif
  34. /*    #include <QuickdrawText.h>                                    */
  35.  
  36. #ifdef __cplusplus
  37. extern "C" {
  38. #endif
  39.  
  40. #if PRAGMA_ALIGN_SUPPORTED
  41. #pragma options align=mac68k
  42. #endif
  43.  
  44. #if PRAGMA_IMPORT_SUPPORTED
  45. #pragma import on
  46. #endif
  47.  
  48.  
  49. enum {
  50.     noMark                        = 0,                            /*mark symbol for MarkItem*/
  51. /* menu defProc messages */
  52.     mDrawMsg                    = 0,
  53.     mChooseMsg                    = 1,
  54.     mSizeMsg                    = 2,
  55.     mDrawItemMsg                = 4,
  56.     mCalcItemMsg                = 5,
  57.     textMenuProc                = 0,
  58.     hMenuCmd                    = 27,                            /*itemCmd == 0x001B ==> hierarchical menu*/
  59.     hierMenu                    = -1,                            /*a hierarchical menu - for InsertMenu call*/
  60.     mPopUpMsg                    = 3,                            /*menu defProc messages - place yourself*/
  61.     mctAllItems                    = -98,                            /*search for all Items for the given ID*/
  62.     mctLastIDIndic                = -99                            /*last color table entry has this in ID field*/
  63. };
  64.  
  65. #ifndef STRICT_MENUS
  66. #define STRICT_MENUS 0
  67. #endif
  68. #if STRICT_MENUS
  69. typedef struct OpaqueMenuRef *MenuRef;
  70.  
  71. typedef MenuRef MenuHandle;
  72.  
  73. #else
  74. struct MenuInfo {
  75.     short                            menuID;
  76.     short                            menuWidth;
  77.     short                            menuHeight;
  78.     Handle                            menuProc;
  79.     long                            enableFlags;
  80.     Str255                            menuData;
  81. };
  82. typedef struct MenuInfo MenuInfo, *MenuPtr, **MenuHandle;
  83.  
  84. typedef MenuHandle MenuRef;
  85.  
  86. #endif
  87. typedef pascal void (*MenuDefProcPtr)(short message, MenuRef theMenu, Rect *menuRect, Point hitPt, short *whichItem);
  88. typedef pascal long (*MenuBarDefProcPtr)(short selector, short message, short parameter1, long parameter2);
  89. typedef pascal void (*MenuHookProcPtr)(void);
  90. typedef pascal short (*MBarHookProcPtr)(Rect *menuRect);
  91.  
  92. #if GENERATINGCFM
  93. typedef UniversalProcPtr MenuDefUPP;
  94. typedef UniversalProcPtr MenuBarDefUPP;
  95. typedef UniversalProcPtr MenuHookUPP;
  96. typedef UniversalProcPtr MBarHookUPP;
  97. #else
  98. typedef MenuDefProcPtr MenuDefUPP;
  99. typedef MenuBarDefProcPtr MenuBarDefUPP;
  100. typedef MenuHookProcPtr MenuHookUPP;
  101. typedef Register68kProcPtr MBarHookUPP;
  102. #endif
  103.  
  104. enum {
  105.     uppMenuDefProcInfo = kPascalStackBased
  106.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(short)))
  107.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(MenuRef)))
  108.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(Rect*)))
  109.          | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(Point)))
  110.          | STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(short*))),
  111.     uppMenuBarDefProcInfo = kPascalStackBased
  112.          | RESULT_SIZE(SIZE_CODE(sizeof(long)))
  113.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(short)))
  114.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(short)))
  115.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(short)))
  116.          | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(long))),
  117.     uppMenuHookProcInfo = kPascalStackBased,
  118.     uppMBarHookProcInfo = SPECIAL_CASE_PROCINFO( kSpecialCaseMBarHook )
  119. };
  120.  
  121. #if GENERATINGCFM
  122. #define NewMenuDefProc(userRoutine)        \
  123.         (MenuDefUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppMenuDefProcInfo, GetCurrentArchitecture())
  124. #define NewMenuBarDefProc(userRoutine)        \
  125.         (MenuBarDefUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppMenuBarDefProcInfo, GetCurrentArchitecture())
  126. #define NewMenuHookProc(userRoutine)        \
  127.         (MenuHookUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppMenuHookProcInfo, GetCurrentArchitecture())
  128. #define NewMBarHookProc(userRoutine)        \
  129.         (MBarHookUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppMBarHookProcInfo, GetCurrentArchitecture())
  130. #else
  131. #define NewMenuDefProc(userRoutine)        \
  132.         ((MenuDefUPP) (userRoutine))
  133. #define NewMenuBarDefProc(userRoutine)        \
  134.         ((MenuBarDefUPP) (userRoutine))
  135. #define NewMenuHookProc(userRoutine)        \
  136.         ((MenuHookUPP) (userRoutine))
  137. #define NewMBarHookProc(userRoutine)        \
  138.         ((MBarHookUPP) (userRoutine))
  139. #endif
  140.  
  141. #if GENERATINGCFM
  142. #define CallMenuDefProc(userRoutine, message, theMenu, menuRect, hitPt, whichItem)        \
  143.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppMenuDefProcInfo, (message), (theMenu), (menuRect), (hitPt), (whichItem))
  144. #define CallMenuBarDefProc(userRoutine, selector, message, parameter1, parameter2)        \
  145.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppMenuBarDefProcInfo, (selector), (message), (parameter1), (parameter2))
  146. #define CallMenuHookProc(userRoutine)        \
  147.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppMenuHookProcInfo)
  148. #define CallMBarHookProc(userRoutine, menuRect)        \
  149.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppMBarHookProcInfo, (menuRect))
  150. #else
  151. #define CallMenuDefProc(userRoutine, message, theMenu, menuRect, hitPt, whichItem)        \
  152.         (*(userRoutine))((message), (theMenu), (menuRect), (hitPt), (whichItem))
  153. #define CallMenuBarDefProc(userRoutine, selector, message, parameter1, parameter2)        \
  154.         (*(userRoutine))((selector), (message), (parameter1), (parameter2))
  155. #define CallMenuHookProc(userRoutine)        \
  156.         (*(userRoutine))()
  157. /* (*MBarHookProcPtr) cannot be called from a high-level language without the Mixed Mode Manager */
  158. #endif
  159.  
  160. struct MCEntry {
  161.     short                            mctID;                        /*menu ID.  ID = 0 is the menu bar*/
  162.     short                            mctItem;                    /*menu Item. Item = 0 is a title*/
  163.     RGBColor                        mctRGB1;                    /*usage depends on ID and Item*/
  164.     RGBColor                        mctRGB2;                    /*usage depends on ID and Item*/
  165.     RGBColor                        mctRGB3;                    /*usage depends on ID and Item*/
  166.     RGBColor                        mctRGB4;                    /*usage depends on ID and Item*/
  167.     short                            mctReserved;                /*reserved for internal use*/
  168. };
  169. typedef struct MCEntry MCEntry;
  170.  
  171. typedef MCEntry *MCEntryPtr;
  172.  
  173. typedef MCEntry MCTable[1], *MCTablePtr, **MCTableHandle;
  174.  
  175. struct MenuCRsrc {
  176.     short                            numEntries;                    /*number of entries*/
  177.     MCTable                            mcEntryRecs;                /*ARRAY [1..numEntries] of MCEntry*/
  178. };
  179. typedef struct MenuCRsrc MenuCRsrc;
  180.  
  181. typedef MenuCRsrc *MenuCRsrcPtr, **MenuCRsrcHandle;
  182.  
  183. extern pascal short GetMBarHeight( void )
  184.     TWOWORDINLINE( 0x3EB8, 0x0BAA ); /* MOVE.w $0BAA,(SP) */
  185. extern pascal void InitMenus(void)
  186.  ONEWORDINLINE(0xA930);
  187. extern pascal MenuRef NewMenu(short menuID, ConstStr255Param menuTitle)
  188.  ONEWORDINLINE(0xA931);
  189. extern pascal MenuRef GetMenu(short resourceID)
  190.  ONEWORDINLINE(0xA9BF);
  191. extern pascal void DisposeMenu(MenuRef theMenu)
  192.  ONEWORDINLINE(0xA932);
  193. extern pascal void AppendMenu(MenuRef menu, ConstStr255Param data)
  194.  ONEWORDINLINE(0xA933);
  195. extern pascal void AppendResMenu(MenuRef theMenu, ResType theType)
  196.  ONEWORDINLINE(0xA94D);
  197. extern pascal void InsertResMenu(MenuRef theMenu, ResType theType, short afterItem)
  198.  ONEWORDINLINE(0xA951);
  199. extern pascal void InsertMenu(MenuRef theMenu, short beforeID)
  200.  ONEWORDINLINE(0xA935);
  201. extern pascal void DrawMenuBar(void)
  202.  ONEWORDINLINE(0xA937);
  203. extern pascal void InvalMenuBar(void)
  204.  ONEWORDINLINE(0xA81D);
  205. extern pascal void DeleteMenu(short menuID)
  206.  ONEWORDINLINE(0xA936);
  207. extern pascal void ClearMenuBar(void)
  208.  ONEWORDINLINE(0xA934);
  209. extern pascal Handle GetNewMBar(short menuBarID)
  210.  ONEWORDINLINE(0xA9C0);
  211. extern pascal Handle GetMenuBar(void)
  212.  ONEWORDINLINE(0xA93B);
  213. extern pascal void SetMenuBar(Handle menuList)
  214.  ONEWORDINLINE(0xA93C);
  215. extern pascal void InsertMenuItem(MenuRef theMenu, ConstStr255Param itemString, short afterItem)
  216.  ONEWORDINLINE(0xA826);
  217. extern pascal void DeleteMenuItem(MenuRef theMenu, short item)
  218.  ONEWORDINLINE(0xA952);
  219. extern pascal long MenuKey(short ch)
  220.  ONEWORDINLINE(0xA93E);
  221. extern pascal void HiliteMenu(short menuID)
  222.  ONEWORDINLINE(0xA938);
  223. extern pascal void SetMenuItemText(MenuRef theMenu, short item, ConstStr255Param itemString)
  224.  ONEWORDINLINE(0xA947);
  225. extern pascal void GetMenuItemText(MenuRef theMenu, short item, Str255 itemString)
  226.  ONEWORDINLINE(0xA946);
  227. extern pascal void DisableItem(MenuRef theMenu, short item)
  228.  ONEWORDINLINE(0xA93A);
  229. extern pascal void EnableItem(MenuRef theMenu, short item)
  230.  ONEWORDINLINE(0xA939);
  231. extern pascal void CheckItem(MenuRef theMenu, short item, Boolean checked)
  232.  ONEWORDINLINE(0xA945);
  233. extern pascal void SetItemMark(MenuRef theMenu, short item, short markChar)
  234.  ONEWORDINLINE(0xA944);
  235. extern pascal void GetItemMark(MenuRef theMenu, short item, short *markChar)
  236.  ONEWORDINLINE(0xA943);
  237. extern pascal void SetItemIcon(MenuRef theMenu, short item, short iconIndex)
  238.  ONEWORDINLINE(0xA940);
  239. extern pascal void GetItemIcon(MenuRef theMenu, short item, short *iconIndex)
  240.  ONEWORDINLINE(0xA93F);
  241. extern pascal void SetItemStyle(MenuRef theMenu, short item, short chStyle)
  242.  ONEWORDINLINE(0xA942);
  243. extern pascal void GetItemStyle(MenuRef theMenu, short item, Style *chStyle);
  244. extern pascal void CalcMenuSize(MenuRef theMenu)
  245.  ONEWORDINLINE(0xA948);
  246. extern pascal short CountMItems(MenuRef theMenu)
  247.  ONEWORDINLINE(0xA950);
  248. #define CountMenuItems(menu) CountMItems(menu)
  249. extern pascal MenuRef GetMenuHandle(short menuID)
  250.  ONEWORDINLINE(0xA949);
  251. extern pascal void FlashMenuBar(short menuID)
  252.  ONEWORDINLINE(0xA94C);
  253. extern pascal void SetMenuFlash(short count)
  254.  ONEWORDINLINE(0xA94A);
  255. extern pascal long MenuSelect(Point startPt)
  256.  ONEWORDINLINE(0xA93D);
  257. extern pascal void InitProcMenu(short resID)
  258.  ONEWORDINLINE(0xA808);
  259. extern pascal void GetItemCmd(MenuRef theMenu, short item, short *cmdChar)
  260.  ONEWORDINLINE(0xA84E);
  261. extern pascal void SetItemCmd(MenuRef theMenu, short item, short cmdChar)
  262.  ONEWORDINLINE(0xA84F);
  263. extern pascal long PopUpMenuSelect(MenuRef menu, short top, short left, short popUpItem)
  264.  ONEWORDINLINE(0xA80B);
  265. extern pascal long MenuChoice(void)
  266.  ONEWORDINLINE(0xAA66);
  267. extern pascal void DeleteMCEntries(short menuID, short menuItem)
  268.  ONEWORDINLINE(0xAA60);
  269. extern pascal MCTableHandle GetMCInfo(void)
  270.  ONEWORDINLINE(0xAA61);
  271. extern pascal void SetMCInfo(MCTableHandle menuCTbl)
  272.  ONEWORDINLINE(0xAA62);
  273. extern pascal void DisposeMCInfo(MCTableHandle menuCTbl)
  274.  ONEWORDINLINE(0xAA63);
  275. extern pascal MCEntryPtr GetMCEntry(short menuID, short menuItem)
  276.  ONEWORDINLINE(0xAA64);
  277. extern pascal void SetMCEntries(short numEntries, MCTablePtr menuCEntries)
  278.  ONEWORDINLINE(0xAA65);
  279. extern pascal void InsertFontResMenu(MenuRef theMenu, short afterItem, short scriptFilter)
  280.  THREEWORDINLINE(0x303C, 0x0400, 0xA825);
  281. extern pascal void InsertIntlResMenu(MenuRef theMenu, ResType theType, short afterItem, short scriptFilter)
  282.  THREEWORDINLINE(0x303C, 0x0601, 0xA825);
  283. extern pascal Boolean SystemEdit(short editCmd)
  284.  ONEWORDINLINE(0xA9C2);
  285. extern pascal void SystemMenu(long menuResult)
  286.  ONEWORDINLINE(0xA9B5);
  287. #if CGLUESUPPORTED
  288. extern MenuRef newmenu(short menuID, const char *menuTitle);
  289. extern void appendmenu(MenuRef menu, const char *data);
  290. extern void insertmenuitem(MenuRef theMenu, const char *itemString, short afterItem);
  291. extern long menuselect(const Point *startPt);
  292. extern void setmenuitemtext(MenuRef menu, short item, const char *itemString);
  293. extern void getmenuitemtext(MenuRef menu, short item, char *itemString);
  294. #endif
  295. #if OLDROUTINENAMES
  296. #define AddResMenu(theMenu, theType) AppendResMenu(theMenu, theType)
  297. #define InsMenuItem(theMenu, itemString, afterItem)  \
  298.     InsertMenuItem(theMenu, itemString, afterItem)
  299. #define DelMenuItem(theMenu, item) DeleteMenuItem(theMenu, item)
  300. #define SetItem(theMenu, item, itemString) SetMenuItemText(theMenu, item, itemString)
  301. #define GetItem(theMenu, item, itemString) GetMenuItemText(theMenu, item, itemString)
  302. #define GetMHandle(menuID) GetMenuHandle(menuID)
  303. #define DelMCEntries(menuID, menuItem) DeleteMCEntries(menuID, menuItem)
  304. #define DispMCInfo(menuCTbl) DisposeMCInfo(menuCTbl)
  305. #if CGLUESUPPORTED
  306. #define addresmenu(menu, data) appendresmenu(menu, data)
  307. #define getitem(menu, item, itemString) getmenuitemtext(menu, item, itemString)
  308. #define setitem(menu, item, itemString) setmenuitemtext(menu, item, itemString)
  309. #define insmenuitem(theMenu, itemString, afterItem)  \
  310.     insertmenuitem(theMenu, itemString, afterItem)
  311. #endif
  312. #endif
  313.  
  314. #if PRAGMA_IMPORT_SUPPORTED
  315. #pragma import off
  316. #endif
  317.  
  318. #if PRAGMA_ALIGN_SUPPORTED
  319. #pragma options align=reset
  320. #endif
  321.  
  322. #ifdef __cplusplus
  323. }
  324. #endif
  325.  
  326. #endif /* __MENUS__ */
  327.